package com.shangqing.document_management.util;

import com.shangqing.document_management.entity.LoggerMessage;
import org.slf4j.MDC;

/**
 * 日志信息工具类
 */
public class LoggerMessageUtil {
    public LoggerMessageUtil(){}
    public static LoggerMessage getLoggerMessage(String userid, String username,String ip,String message){
        LoggerMessage loggerMessage=new LoggerMessage();
        loggerMessage.setUserid(userid);
        loggerMessage.setUsername(username);
        loggerMessage.setIp(ip);
        loggerMessage.setMessage(message);
        return loggerMessage;
    }

    /**
     * 将要输入表中的数据存在MDC中
     * @param loggerMessage
     */
    public static void getMDC(LoggerMessage loggerMessage){
        MDC.put("USERID",loggerMessage.getUserid());
        MDC.put("USERNAME",loggerMessage.getUsername());
        MDC.put("IP",loggerMessage.getIp());
        MDC.put("MESSAGE",loggerMessage.getMessage());
    }
}
